<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<style type="text/css">
body {white-space: pre-wrap;
font-family:"楷体",Monospace;
font-size:12px;
font-weight:bold;
}
</style>
</head>
<body><span style = "background-color: #F0F0F0;">  0</span>| <span style="color: rgb(255,0,0)">#include &#60;iostream&#62;</span>
<span style = "background-color: #F0F0F0;">  1</span>| <span style="color: rgb(255,0,0)">#include &#60;fstream&#62;</span>
<span style = "background-color: #F0F0F0;">  2</span>| <span style="color: rgb(255,0,0)">#include &#60;cstdio&#62;</span>
<span style = "background-color: #F0F0F0;">  3</span>| <span style="color: rgb(255,0,0)">#include &#60;string&#62;</span>
<span style = "background-color: #F0F0F0;">  4</span>| <span style="color: rgb(255,0,0)">#include &#60;algorithm&#62;</span>
<span style = "background-color: #F0F0F0;">  5</span>| <span style="color: rgb(255,0,0)">#include &#60;vector&#62;</span>
<span style = "background-color: #F0F0F0;">  6</span>| <span style="color: rgb(255,0,0)">#include &#60;ctime&#62;</span>
<span style = "background-color: #F0F0F0;">  7</span>| <span style="color: rgb(255,0,0)">#include &#60;cstdlib&#62;</span>
<span style = "background-color: #F0F0F0;">  8</span>| <span style="color: rgb(255,0,0)">#include &#60;windows.h&#62;</span>
<span style = "background-color: #F0F0F0;">  9</span>| <span style="color: rgb(255,0,0)">#include &#60;conio.h&#62;</span>
<span style = "background-color: #F0F0F0;"> 10</span>| <span style="color: rgb(0,0,255)">using</span> <span style="color: rgb(0,0,255)">namespace</span> std;
<span style = "background-color: #F0F0F0;"> 11</span>| <span style="color: rgb(0,0,255)">class</span> incident
<span style = "background-color: #F0F0F0;"> 12</span>| {
<span style = "background-color: #F0F0F0;"> 13</span>| 	<span style="color: rgb(0,0,255)">private</span>:
<span style = "background-color: #F0F0F0;"> 14</span>| 	string title;<span style="color: rgb(128,128,128)">//事件标题</span>
<span style = "background-color: #F0F0F0;"> 15</span>| 	string body;<span style="color: rgb(128,128,128)">//事件内容</span>
<span style = "background-color: #F0F0F0;"> 16</span>| 	time_t occur_time;<span style="color: rgb(128,128,128)">//事件发生时间</span>
<span style = "background-color: #F0F0F0;"> 17</span>| 	<span style="color: rgb(0,0,255)">struct</span> tm stime;<span style="color: rgb(128,128,128)">//事件发生时间(tm 结构)</span>
<span style = "background-color: #F0F0F0;"> 18</span>| 	<span style="color: rgb(0,0,255)">int</span> interval;<span style="color: rgb(128,128,128)">//间隔时间</span>
<span style = "background-color: #F0F0F0;"> 19</span>| 	<span style="color: rgb(0,0,255)">int</span> warn_times;<span style="color: rgb(128,128,128)">//提醒次数</span>
<span style = "background-color: #F0F0F0;"> 20</span>| 	<span style="color: rgb(0,0,255)">public</span>:
<span style = "background-color: #F0F0F0;"> 21</span>| 	incident()<span style="color: rgb(128,128,128)">//事件初始化</span>
<span style = "background-color: #F0F0F0;"> 22</span>| 	{
<span style = "background-color: #F0F0F0;"> 23</span>| 		title="新事件";
<span style = "background-color: #F0F0F0;"> 24</span>| 		body="It's time!! \(^o^)/";
<span style = "background-color: #F0F0F0;"> 25</span>| 		interval=300;<span style="color: rgb(128,128,128)">//间隔5分钟</span>
<span style = "background-color: #F0F0F0;"> 26</span>| 		warn_times=3;<span style="color: rgb(128,128,128)">//提醒次数3</span>
<span style = "background-color: #F0F0F0;"> 27</span>| 		occur_time=time(0)+3600;
<span style = "background-color: #F0F0F0;"> 28</span>| 		stime=*localtime(&#38;occur_time);
<span style = "background-color: #F0F0F0;"> 29</span>| 		stime.tm_sec=0;
<span style = "background-color: #F0F0F0;"> 30</span>| 		occur_time=mktime(&#38;stime);
<span style = "background-color: #F0F0F0;"> 31</span>| 	}
<span style = "background-color: #F0F0F0;"> 32</span>| 	<span style="color: rgb(0,0,255)">int</span> set_title(string s)<span style="color: rgb(128,128,128)">//设置标题(1~21)字符为合法</span>
<span style = "background-color: #F0F0F0;"> 33</span>| 	{
<span style = "background-color: #F0F0F0;"> 34</span>| 		<span style="color: rgb(0,0,255)">if</span>(s.size()&#60;=21)
<span style = "background-color: #F0F0F0;"> 35</span>| 		{
<span style = "background-color: #F0F0F0;"> 36</span>| 			<span style="color: rgb(0,0,255)">if</span>(!s.empty())
<span style = "background-color: #F0F0F0;"> 37</span>| 				title=s;
<span style = "background-color: #F0F0F0;"> 38</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;"> 39</span>| 		}
<span style = "background-color: #F0F0F0;"> 40</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;"> 41</span>| 	}
<span style = "background-color: #F0F0F0;"> 42</span>| 	<span style="color: rgb(0,0,255)">int</span> set_body(string s)<span style="color: rgb(128,128,128)">//设置内容(1~41)字符为合法</span>
<span style = "background-color: #F0F0F0;"> 43</span>| 	{
<span style = "background-color: #F0F0F0;"> 44</span>| 		<span style="color: rgb(0,0,255)">if</span>(s.size()&#60;=41)
<span style = "background-color: #F0F0F0;"> 45</span>| 		{
<span style = "background-color: #F0F0F0;"> 46</span>| 			<span style="color: rgb(0,0,255)">if</span>(!s.empty())
<span style = "background-color: #F0F0F0;"> 47</span>| 				body=s;
<span style = "background-color: #F0F0F0;"> 48</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;"> 49</span>| 		}
<span style = "background-color: #F0F0F0;"> 50</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;"> 51</span>| 	}
<span style = "background-color: #F0F0F0;"> 52</span>| 	<span style="color: rgb(0,0,255)">int</span> set_year(<span style="color: rgb(0,0,255)">int</span> y)<span style="color: rgb(128,128,128)">//(1970~2029)合法</span>
<span style = "background-color: #F0F0F0;"> 53</span>| 	{
<span style = "background-color: #F0F0F0;"> 54</span>| 		<span style="color: rgb(0,0,255)">if</span>(y&#62;=1970&#38;&#38;y&#60;2030)
<span style = "background-color: #F0F0F0;"> 55</span>| 		{
<span style = "background-color: #F0F0F0;"> 56</span>| 			stime.tm_year=y-1900;
<span style = "background-color: #F0F0F0;"> 57</span>| 			occur_time=mktime(&#38;stime);
<span style = "background-color: #F0F0F0;"> 58</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;"> 59</span>| 		}
<span style = "background-color: #F0F0F0;"> 60</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;"> 61</span>| 	}
<span style = "background-color: #F0F0F0;"> 62</span>| 	<span style="color: rgb(0,0,255)">int</span> set_mon(<span style="color: rgb(0,0,255)">int</span> m)<span style="color: rgb(128,128,128)">//1~12合法</span>
<span style = "background-color: #F0F0F0;"> 63</span>| 	{
<span style = "background-color: #F0F0F0;"> 64</span>| 		<span style="color: rgb(0,0,255)">if</span>(m&#62;=1&#38;&#38;m&#60;=12)
<span style = "background-color: #F0F0F0;"> 65</span>| 		{
<span style = "background-color: #F0F0F0;"> 66</span>| 			stime.tm_mon=m-1;
<span style = "background-color: #F0F0F0;"> 67</span>| 			occur_time=mktime(&#38;stime);
<span style = "background-color: #F0F0F0;"> 68</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;"> 69</span>| 		}
<span style = "background-color: #F0F0F0;"> 70</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;"> 71</span>| 	}
<span style = "background-color: #F0F0F0;"> 72</span>| 	<span style="color: rgb(0,0,255)">int</span> set_day(<span style="color: rgb(0,0,255)">int</span> d)<span style="color: rgb(128,128,128)">//1~31合法</span>
<span style = "background-color: #F0F0F0;"> 73</span>| 	{
<span style = "background-color: #F0F0F0;"> 74</span>| 		<span style="color: rgb(0,0,255)">if</span>(d&#62;=1&#38;&#38;d&#60;=31)
<span style = "background-color: #F0F0F0;"> 75</span>| 		{
<span style = "background-color: #F0F0F0;"> 76</span>| 			stime.tm_mday=d;
<span style = "background-color: #F0F0F0;"> 77</span>| 			occur_time=mktime(&#38;stime);
<span style = "background-color: #F0F0F0;"> 78</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;"> 79</span>| 		}
<span style = "background-color: #F0F0F0;"> 80</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;"> 81</span>| 	}
<span style = "background-color: #F0F0F0;"> 82</span>| 	<span style="color: rgb(0,0,255)">int</span> set_hour(<span style="color: rgb(0,0,255)">int</span> h)<span style="color: rgb(128,128,128)">//1~24合法</span>
<span style = "background-color: #F0F0F0;"> 83</span>| 	{
<span style = "background-color: #F0F0F0;"> 84</span>| 		<span style="color: rgb(0,0,255)">if</span>(h&#62;=0&#38;&#38;h&#60;=23)
<span style = "background-color: #F0F0F0;"> 85</span>| 		{
<span style = "background-color: #F0F0F0;"> 86</span>| 			stime.tm_hour=h;
<span style = "background-color: #F0F0F0;"> 87</span>| 			occur_time=mktime(&#38;stime);
<span style = "background-color: #F0F0F0;"> 88</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;"> 89</span>| 		}
<span style = "background-color: #F0F0F0;"> 90</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;"> 91</span>| 	}
<span style = "background-color: #F0F0F0;"> 92</span>| 	<span style="color: rgb(0,0,255)">int</span> set_min(<span style="color: rgb(0,0,255)">int</span> m)<span style="color: rgb(128,128,128)">//0~59合法</span>
<span style = "background-color: #F0F0F0;"> 93</span>| 	{
<span style = "background-color: #F0F0F0;"> 94</span>| 		<span style="color: rgb(0,0,255)">if</span>(m&#62;=0&#38;&#38;m&#60;=59)
<span style = "background-color: #F0F0F0;"> 95</span>| 		{
<span style = "background-color: #F0F0F0;"> 96</span>| 			stime.tm_min=m;
<span style = "background-color: #F0F0F0;"> 97</span>| 			occur_time=mktime(&#38;stime);
<span style = "background-color: #F0F0F0;"> 98</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;"> 99</span>| 		}
<span style = "background-color: #F0F0F0;">100</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">101</span>| 	}
<span style = "background-color: #F0F0F0;">102</span>| 	<span style="color: rgb(0,0,255)">int</span> set_warn_times(<span style="color: rgb(0,0,255)">int</span> m)<span style="color: rgb(128,128,128)">//1~10合法</span>
<span style = "background-color: #F0F0F0;">103</span>| 	{
<span style = "background-color: #F0F0F0;">104</span>| 		<span style="color: rgb(0,0,255)">if</span>(m&#62;=1&#38;&#38;m&#60;=10)
<span style = "background-color: #F0F0F0;">105</span>| 		{
<span style = "background-color: #F0F0F0;">106</span>| 			warn_times=m;
<span style = "background-color: #F0F0F0;">107</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">108</span>| 		}
<span style = "background-color: #F0F0F0;">109</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">110</span>| 	}
<span style = "background-color: #F0F0F0;">111</span>| 	<span style="color: rgb(0,0,255)">int</span> set_interval(<span style="color: rgb(0,0,255)">int</span> m)<span style="color: rgb(128,128,128)">//分钟为单位,最长间隔1天</span>
<span style = "background-color: #F0F0F0;">112</span>| 	{
<span style = "background-color: #F0F0F0;">113</span>| 		<span style="color: rgb(0,0,255)">if</span>(m&#62;=1&#38;&#38;m&#60;=60*24)
<span style = "background-color: #F0F0F0;">114</span>| 		{
<span style = "background-color: #F0F0F0;">115</span>| 			interval=m*60;
<span style = "background-color: #F0F0F0;">116</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">117</span>| 		}
<span style = "background-color: #F0F0F0;">118</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">119</span>| 	}
<span style = "background-color: #F0F0F0;">120</span>| 	<span style="color: rgb(0,0,255)">void</span> out(fstream &#38;f)<span style="color: rgb(128,128,128)">//把数据写入文件对象</span>
<span style = "background-color: #F0F0F0;">121</span>| 	{
<span style = "background-color: #F0F0F0;">122</span>| 		f&#60;&#60;title&#60;&#60;endl&#60;&#60;body&#60;&#60;endl&#60;&#60;occur_time&#60;&#60;endl&#60;&#60;interval&#60;&#60;endl&#60;&#60;warn_times&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">123</span>| 	}
<span style = "background-color: #F0F0F0;">124</span>| 	<span style="color: rgb(0,0,255)">int</span> postpond()<span style="color: rgb(128,128,128)">//延迟事件</span>
<span style = "background-color: #F0F0F0;">125</span>| 	{
<span style = "background-color: #F0F0F0;">126</span>| 		<span style="color: rgb(0,0,255)">if</span>(warn_times&#62;1)
<span style = "background-color: #F0F0F0;">127</span>| 		{
<span style = "background-color: #F0F0F0;">128</span>| 			warn_times--;
<span style = "background-color: #F0F0F0;">129</span>| 			occur_time=time(0)+interval;
<span style = "background-color: #F0F0F0;">130</span>| 			stime=*localtime(&#38;occur_time);
<span style = "background-color: #F0F0F0;">131</span>| 			stime.tm_sec=0;
<span style = "background-color: #F0F0F0;">132</span>| 			occur_time=mktime(&#38;stime);
<span style = "background-color: #F0F0F0;">133</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">134</span>| 		}
<span style = "background-color: #F0F0F0;">135</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">136</span>| 	}
<span style = "background-color: #F0F0F0;">137</span>| 	<span style="color: rgb(0,0,255)">int</span> in(fstream &#38;f)<span style="color: rgb(128,128,128)">//把文件对象数据写入</span>
<span style = "background-color: #F0F0F0;">138</span>| 	{
<span style = "background-color: #F0F0F0;">139</span>| 		<span style="color: rgb(0,0,255)">char</span> c;
<span style = "background-color: #F0F0F0;">140</span>| 		<span style="color: rgb(0,0,255)">if</span>(!f.eof())
<span style = "background-color: #F0F0F0;">141</span>| 		{
<span style = "background-color: #F0F0F0;">142</span>| 			getline(f,title,'\n');
<span style = "background-color: #F0F0F0;">143</span>| 			<span style="color: rgb(0,0,255)">if</span>(f.eof()) <span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">144</span>| 			getline(f,body,'\n');
<span style = "background-color: #F0F0F0;">145</span>| 			f&#62;&#62;occur_time&#62;&#62;interval&#62;&#62;warn_times;
<span style = "background-color: #F0F0F0;">146</span>| 			stime=*localtime(&#38;occur_time);
<span style = "background-color: #F0F0F0;">147</span>| 			c=f.get();
<span style = "background-color: #F0F0F0;">148</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">149</span>| 		}
<span style = "background-color: #F0F0F0;">150</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">151</span>| 	}
<span style = "background-color: #F0F0F0;">152</span>| 	<span style="color: rgb(128,128,128)">//下面的很直观</span>
<span style = "background-color: #F0F0F0;">153</span>| 	<span style="color: rgb(0,0,255)">const</span> time_t* get_time()
<span style = "background-color: #F0F0F0;">154</span>| 	{
<span style = "background-color: #F0F0F0;">155</span>| 		<span style="color: rgb(0,0,255)">return</span> &#38;occur_time;
<span style = "background-color: #F0F0F0;">156</span>| 	}
<span style = "background-color: #F0F0F0;">157</span>| 	string get_title()
<span style = "background-color: #F0F0F0;">158</span>| 	{
<span style = "background-color: #F0F0F0;">159</span>| 		<span style="color: rgb(0,0,255)">return</span> title;
<span style = "background-color: #F0F0F0;">160</span>| 	}
<span style = "background-color: #F0F0F0;">161</span>| 	string get_body()
<span style = "background-color: #F0F0F0;">162</span>| 	{
<span style = "background-color: #F0F0F0;">163</span>| 		<span style="color: rgb(0,0,255)">return</span> body;
<span style = "background-color: #F0F0F0;">164</span>| 	}
<span style = "background-color: #F0F0F0;">165</span>| 	<span style="color: rgb(0,0,255)">int</span> get_interval()
<span style = "background-color: #F0F0F0;">166</span>| 	{
<span style = "background-color: #F0F0F0;">167</span>| 		<span style="color: rgb(0,0,255)">return</span> interval;
<span style = "background-color: #F0F0F0;">168</span>| 	}
<span style = "background-color: #F0F0F0;">169</span>| 	<span style="color: rgb(0,0,255)">int</span> get_warn_times()
<span style = "background-color: #F0F0F0;">170</span>| 	{
<span style = "background-color: #F0F0F0;">171</span>| 		<span style="color: rgb(0,0,255)">return</span> warn_times;
<span style = "background-color: #F0F0F0;">172</span>| 	}
<span style = "background-color: #F0F0F0;">173</span>| };
<span style = "background-color: #F0F0F0;">174</span>| <span style="color: rgb(0,0,255)">class</span> handle
<span style = "background-color: #F0F0F0;">175</span>| {
<span style = "background-color: #F0F0F0;">176</span>| 	<span style="color: rgb(0,0,255)">public</span>:
<span style = "background-color: #F0F0F0;">177</span>| 	vector&#60;incident&#62; inc;<span style="color: rgb(128,128,128)">//计划事件的动态数组(事件表)</span>
<span style = "background-color: #F0F0F0;">178</span>| 	vector&#60;incident&#62; inc_o;<span style="color: rgb(128,128,128)">//过期事件的动态数组(事件表)</span>
<span style = "background-color: #F0F0F0;">179</span>| 	<span style="color: rgb(0,0,255)">public</span>:
<span style = "background-color: #F0F0F0;">180</span>| 	handle()
<span style = "background-color: #F0F0F0;">181</span>| 	{
<span style = "background-color: #F0F0F0;">182</span>| 		load();
<span style = "background-color: #F0F0F0;">183</span>| 	}
<span style = "background-color: #F0F0F0;">184</span>| 	<span style="color: rgb(0,0,255)">void</span> load()<span style="color: rgb(128,128,128)">//从文件data读入数据,按时间存入inc或inc_o,文件不存在的话新建</span>
<span style = "background-color: #F0F0F0;">185</span>| 	{
<span style = "background-color: #F0F0F0;">186</span>| 		incident t;
<span style = "background-color: #F0F0F0;">187</span>| 		time_t nt;
<span style = "background-color: #F0F0F0;">188</span>| 		fstream f("data");
<span style = "background-color: #F0F0F0;">189</span>| 		<span style="color: rgb(0,0,255)">if</span>(!f)
<span style = "background-color: #F0F0F0;">190</span>| 		{
<span style = "background-color: #F0F0F0;">191</span>| 			f.open("data",ios::out);
<span style = "background-color: #F0F0F0;">192</span>| 			f.close();
<span style = "background-color: #F0F0F0;">193</span>| 			f.clear();<span style="color: rgb(128,128,128)">//呕心的C++新标准</span>
<span style = "background-color: #F0F0F0;">194</span>| 			f.open("data");
<span style = "background-color: #F0F0F0;">195</span>| 		}
<span style = "background-color: #F0F0F0;">196</span>| 		<span style="color: rgb(0,0,255)">if</span>(!inc.empty()) inc.clear();
<span style = "background-color: #F0F0F0;">197</span>| 		<span style="color: rgb(0,0,255)">if</span>(!inc_o.empty()) inc_o.clear();
<span style = "background-color: #F0F0F0;">198</span>| 		<span style="color: rgb(0,0,255)">while</span>(t.in(f))
<span style = "background-color: #F0F0F0;">199</span>| 		{
<span style = "background-color: #F0F0F0;">200</span>| 			nt=time(0);
<span style = "background-color: #F0F0F0;">201</span>| 			<span style="color: rgb(0,0,255)">if</span>(*(t.get_time())&#62;nt-50)
<span style = "background-color: #F0F0F0;">202</span>| 				inc.push_back(t);
<span style = "background-color: #F0F0F0;">203</span>| 			<span style="color: rgb(0,0,255)">else</span>
<span style = "background-color: #F0F0F0;">204</span>| 				inc_o.push_back(t);
<span style = "background-color: #F0F0F0;">205</span>| 		}
<span style = "background-color: #F0F0F0;">206</span>| 		f.close();
<span style = "background-color: #F0F0F0;">207</span>| 		_sort();
<span style = "background-color: #F0F0F0;">208</span>| 	}
<span style = "background-color: #F0F0F0;">209</span>| 	<span style="color: rgb(0,0,255)">void</span> save()<span style="color: rgb(128,128,128)">//把所有事件存入data文件</span>
<span style = "background-color: #F0F0F0;">210</span>| 	{
<span style = "background-color: #F0F0F0;">211</span>| 		fstream f("data",ios::out);
<span style = "background-color: #F0F0F0;">212</span>| 		<span style="color: rgb(0,0,255)">for</span>(<span style="color: rgb(0,0,255)">int</span> i=0;i&#60;inc.size();i++)
<span style = "background-color: #F0F0F0;">213</span>| 		{
<span style = "background-color: #F0F0F0;">214</span>| 			inc[i].out(f);
<span style = "background-color: #F0F0F0;">215</span>| 		}
<span style = "background-color: #F0F0F0;">216</span>| 		<span style="color: rgb(0,0,255)">for</span>(<span style="color: rgb(0,0,255)">int</span> i=0;i&#60;inc_o.size();i++)
<span style = "background-color: #F0F0F0;">217</span>| 		{
<span style = "background-color: #F0F0F0;">218</span>| 			inc_o[i].out(f);
<span style = "background-color: #F0F0F0;">219</span>| 		}
<span style = "background-color: #F0F0F0;">220</span>| 		f.close();
<span style = "background-color: #F0F0F0;">221</span>| 	}
<span style = "background-color: #F0F0F0;">222</span>| 	<span style="color: rgb(0,0,255)">void</span> add()<span style="color: rgb(128,128,128)">//新建事件插入计划事件表</span>
<span style = "background-color: #F0F0F0;">223</span>| 	{
<span style = "background-color: #F0F0F0;">224</span>| 		incident t;
<span style = "background-color: #F0F0F0;">225</span>| 		inc.push_back(t);
<span style = "background-color: #F0F0F0;">226</span>| 	}
<span style = "background-color: #F0F0F0;">227</span>| 	<span style="color: rgb(0,0,255)">int</span> del(<span style="color: rgb(0,0,255)">int</span> vi,vector&#60;incident&#62; &#38;inct)<span style="color: rgb(128,128,128)">//删除时间表中vi 位置的对象</span>
<span style = "background-color: #F0F0F0;">228</span>| 	{
<span style = "background-color: #F0F0F0;">229</span>| 		<span style="color: rgb(0,0,255)">if</span>(vi&#60;inct.size())
<span style = "background-color: #F0F0F0;">230</span>|   		{
<span style = "background-color: #F0F0F0;">231</span>| 			swap(inct[vi],inct.back());
<span style = "background-color: #F0F0F0;">232</span>| 			inct.pop_back();
<span style = "background-color: #F0F0F0;">233</span>| 		}
<span style = "background-color: #F0F0F0;">234</span>| 		_sort();
<span style = "background-color: #F0F0F0;">235</span>| 		save();
<span style = "background-color: #F0F0F0;">236</span>| 	}
<span style = "background-color: #F0F0F0;">237</span>| 	<span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">bool</span> comp(incident a,incident b)<span style="color: rgb(128,128,128)">//为 sort函数传入比较函数</span>
<span style = "background-color: #F0F0F0;">238</span>| 	{
<span style = "background-color: #F0F0F0;">239</span>| 		<span style="color: rgb(0,0,255)">return</span> *a.get_time()&#60;*b.get_time();
<span style = "background-color: #F0F0F0;">240</span>| 	}
<span style = "background-color: #F0F0F0;">241</span>| 	<span style="color: rgb(0,0,255)">void</span> _sort()<span style="color: rgb(128,128,128)">//对两个事件表排序</span>
<span style = "background-color: #F0F0F0;">242</span>| 	{
<span style = "background-color: #F0F0F0;">243</span>| 		sort(inc.begin(),inc.end(),comp);
<span style = "background-color: #F0F0F0;">244</span>| 		sort(inc_o.begin(),inc_o.end(),comp);
<span style = "background-color: #F0F0F0;">245</span>| 	}
<span style = "background-color: #F0F0F0;">246</span>| 	<span style="color: rgb(0,0,255)">int</span> <span style="color: rgb(0,0,255)">if</span>_alarm()<span style="color: rgb(128,128,128)">//判断最近期的计划事件是否到提醒时间</span>
<span style = "background-color: #F0F0F0;">247</span>| 	{
<span style = "background-color: #F0F0F0;">248</span>| 		<span style="color: rgb(0,0,255)">if</span>(!inc.empty())
<span style = "background-color: #F0F0F0;">249</span>| 		{
<span style = "background-color: #F0F0F0;">250</span>| 			time_t ct = *(inc[0].get_time());
<span style = "background-color: #F0F0F0;">251</span>| 			<span style="color: rgb(0,0,255)">if</span>(ct&#60;=time(0)&#38;&#38;ct+60&#62;=time(0))
<span style = "background-color: #F0F0F0;">252</span>| 				<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">253</span>| 		}
<span style = "background-color: #F0F0F0;">254</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">255</span>| 	}
<span style = "background-color: #F0F0F0;">256</span>| 	<span style="color: rgb(0,0,255)">void</span> postpond(<span style="color: rgb(0,0,255)">char</span> c)<span style="color: rgb(128,128,128)">//char c为下面应用时的参数 当c为Esc（用户确认）时直接推入过期事件表</span>
<span style = "background-color: #F0F0F0;">257</span>| 	{
<span style = "background-color: #F0F0F0;">258</span>| 		<span style="color: rgb(0,0,255)">if</span>(c==27||!inc[0].postpond())
<span style = "background-color: #F0F0F0;">259</span>| 		{
<span style = "background-color: #F0F0F0;">260</span>| 			inc_o.push_back(inc[0]);
<span style = "background-color: #F0F0F0;">261</span>| 			del(0,inc);
<span style = "background-color: #F0F0F0;">262</span>| 		}
<span style = "background-color: #F0F0F0;">263</span>| 		_sort();
<span style = "background-color: #F0F0F0;">264</span>| 		save();
<span style = "background-color: #F0F0F0;">265</span>| 	}
<span style = "background-color: #F0F0F0;">266</span>| };
<span style = "background-color: #F0F0F0;">267</span>| <span style="color: rgb(0,0,255)">class</span> ui
<span style = "background-color: #F0F0F0;">268</span>| {
<span style = "background-color: #F0F0F0;">269</span>| 	<span style="color: rgb(0,0,255)">private</span>:
<span style = "background-color: #F0F0F0;">270</span>| 	handle op;<span style="color: rgb(128,128,128)">//唯一与handle类的联系</span>
<span style = "background-color: #F0F0F0;">271</span>| 	time_t nt;<span style="color: rgb(128,128,128)">//当前系统时间</span>
<span style = "background-color: #F0F0F0;">272</span>| 	<span style="color: rgb(0,0,255)">public</span>:
<span style = "background-color: #F0F0F0;">273</span>| 	<span style="color: rgb(0,0,255)">void</span> print(incident &#38;i)<span style="color: rgb(128,128,128)">//打印事件属性</span>
<span style = "background-color: #F0F0F0;">274</span>| 	{
<span style = "background-color: #F0F0F0;">275</span>| 		cout&#60;&#60;"\t\t---------------------------------------"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">276</span>| 		cout&#60;&#60;"\t\t标题: "&#60;&#60;i.get_title()&#60;&#60;endl&#60;&#60;"\t\t内容: "&#60;&#60;i.get_body()&#60;&#60;endl&#60;&#60;"\t\t时间: "&#60;&#60;ctime(i.get_time());
<span style = "background-color: #F0F0F0;">277</span>| 		cout&#60;&#60;"\t\t提醒间隔: "&#60;&#60;i.get_interval()/60&#60;&#60;"分钟"&#60;&#60;"\t\t提醒次数: "&#60;&#60;i.get_warn_times()&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">278</span>| 		cout&#60;&#60;"\t\t---------------------------------------"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">279</span>| 	}
<span style = "background-color: #F0F0F0;">280</span>| 	<span style="color: rgb(0,0,255)">int</span> alarm()<span style="color: rgb(128,128,128)">//闹铃界面</span>
<span style = "background-color: #F0F0F0;">281</span>| 	{
<span style = "background-color: #F0F0F0;">282</span>| 		<span style="color: rgb(0,0,255)">char</span> c;
<span style = "background-color: #F0F0F0;">283</span>| 		<span style="color: rgb(0,0,255)">if</span>(op.<span style="color: rgb(0,0,255)">if</span>_alarm())
<span style = "background-color: #F0F0F0;">284</span>| 		{
<span style = "background-color: #F0F0F0;">285</span>| 			system("cls");
<span style = "background-color: #F0F0F0;">286</span>| 			cout&#60;&#60;"\t\t***************************************"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">287</span>| 			nt=time(0);
<span style = "background-color: #F0F0F0;">288</span>| 			cout&#60;&#60;"\t\t系统时间:  "&#60;&#60;ctime(&#38;nt);
<span style = "background-color: #F0F0F0;">289</span>| 			cout&#60;&#60;"\t\t***************************************"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">290</span>| 			cout&#60;&#60;"\n\t\t闹铃时间到!!\n\n "&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">291</span>| 			print(op.inc[0]);
<span style = "background-color: #F0F0F0;">292</span>| 			cout&#60;&#60;"\n\t\t请输入Esc确认返回"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">293</span>| 			GoToXY(40,21);
<span style = "background-color: #F0F0F0;">294</span>| 			cout&#60;&#60;"结构化程序设计课程设计"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">295</span>| 			GoToXY(35,23);
<span style = "background-color: #F0F0F0;">296</span>| 			cout&#60;&#60;"Designed By 09计机5 @ SCAU 连泽祺"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">297</span>| 			<span style="color: rgb(0,0,255)">while</span>(op.<span style="color: rgb(0,0,255)">if</span>_alarm())
<span style = "background-color: #F0F0F0;">298</span>| 			{
<span style = "background-color: #F0F0F0;">299</span>| 				<span style="color: rgb(0,0,255)">if</span>(kbhit())
<span style = "background-color: #F0F0F0;">300</span>| 				{
<span style = "background-color: #F0F0F0;">301</span>| 					c=getch();
<span style = "background-color: #F0F0F0;">302</span>| 					<span style="color: rgb(0,0,255)">if</span>(c==27)
<span style = "background-color: #F0F0F0;">303</span>| 					{
<span style = "background-color: #F0F0F0;">304</span>| 						op.postpond(c);
<span style = "background-color: #F0F0F0;">305</span>| 						<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">306</span>| 					}
<span style = "background-color: #F0F0F0;">307</span>| 				}
<span style = "background-color: #F0F0F0;">308</span>| 				cout&#60;&#60;"\a\a";
<span style = "background-color: #F0F0F0;">309</span>| 				GoToXY(0,1);
<span style = "background-color: #F0F0F0;">310</span>| 				nt=time(0);
<span style = "background-color: #F0F0F0;">311</span>| 				cout&#60;&#60;"\t\t系统时间:  "&#60;&#60;ctime(&#38;nt)&#60;&#60;endl&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">312</span>| 				Sleep(1000);
<span style = "background-color: #F0F0F0;">313</span>| 			}
<span style = "background-color: #F0F0F0;">314</span>| 			op.postpond(0);
<span style = "background-color: #F0F0F0;">315</span>| 			<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">316</span>| 		}
<span style = "background-color: #F0F0F0;">317</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">318</span>| 	}
<span style = "background-color: #F0F0F0;">319</span>| 	<span style="color: rgb(0,0,255)">int</span> index()<span style="color: rgb(128,128,128)">//主界面</span>
<span style = "background-color: #F0F0F0;">320</span>| 	{
<span style = "background-color: #F0F0F0;">321</span>| 		system("cls");
<span style = "background-color: #F0F0F0;">322</span>| 		cout&#60;&#60;"\t\t***************************************"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">323</span>| 		nt=time(0);
<span style = "background-color: #F0F0F0;">324</span>| 		cout&#60;&#60;"\t\t系统时间:  "&#60;&#60;ctime(&#38;nt);
<span style = "background-color: #F0F0F0;">325</span>| 		cout&#60;&#60;"\t\t***************************************"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">326</span>| 		cout&#60;&#60;"\t\t---------------------------------------"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">327</span>| 		cout&#60;&#60;"\t\t\t   记事提醒程序 v1.1"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">328</span>| 		cout&#60;&#60;"\t\t---------------------------------------"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">329</span>| 		<span style="color: rgb(0,0,255)">if</span>(op.inc.empty())
<span style = "background-color: #F0F0F0;">330</span>| 		{
<span style = "background-color: #F0F0F0;">331</span>| 			cout&#60;&#60;"\n\n\t\t╮(╯▽╰)╭ 最近没有提醒事件!!\n"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">332</span>| 			cout&#60;&#60;endl&#60;&#60;"\t\t请选择操作:  1.添加事件   ";
<span style = "background-color: #F0F0F0;">333</span>| 			<span style="color: rgb(0,0,255)">if</span>(!op.inc_o.empty())
<span style = "background-color: #F0F0F0;">334</span>| 				cout&#60;&#60;"2.查看/修改/删除(过期事件)";
<span style = "background-color: #F0F0F0;">335</span>| 		}
<span style = "background-color: #F0F0F0;">336</span>| 		<span style="color: rgb(0,0,255)">else</span>
<span style = "background-color: #F0F0F0;">337</span>| 		{
<span style = "background-color: #F0F0F0;">338</span>| 			cout&#60;&#60;"\n\t\t最新事件: "&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">339</span>| 			print(op.inc[0]);
<span style = "background-color: #F0F0F0;">340</span>| 			cout&#60;&#60;endl&#60;&#60;"\t\t请选择操作:\n\n\t\t1.添加事件   2.查看/修改/删除   ";
<span style = "background-color: #F0F0F0;">341</span>| 			<span style="color: rgb(0,0,255)">if</span>(!op.inc_o.empty())
<span style = "background-color: #F0F0F0;">342</span>| 				cout&#60;&#60;"3.查看过期事件";
<span style = "background-color: #F0F0F0;">343</span>| 		}
<span style = "background-color: #F0F0F0;">344</span>| 		cout&#60;&#60;"\n\n\t\tEsc 退出程序"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">345</span>| 		GoToXY(40,21);
<span style = "background-color: #F0F0F0;">346</span>| 		cout&#60;&#60;"结构化程序设计课程设计"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">347</span>| 		GoToXY(35,23);
<span style = "background-color: #F0F0F0;">348</span>| 		cout&#60;&#60;"Designed By 09计机5 @ SCAU 连泽祺"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">349</span>| 		<span style="color: rgb(0,0,255)">while</span>(1)
<span style = "background-color: #F0F0F0;">350</span>| 		{
<span style = "background-color: #F0F0F0;">351</span>| 			<span style="color: rgb(0,0,255)">if</span>(alarm()) <span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">352</span>| 			<span style="color: rgb(0,0,255)">if</span>(kbhit())
<span style = "background-color: #F0F0F0;">353</span>| 			{
<span style = "background-color: #F0F0F0;">354</span>| 				<span style="color: rgb(0,0,255)">char</span> c=getch();
<span style = "background-color: #F0F0F0;">355</span>| 				<span style="color: rgb(0,0,255)">if</span>(op.inc.empty())
<span style = "background-color: #F0F0F0;">356</span>| 				{
<span style = "background-color: #F0F0F0;">357</span>| 					<span style="color: rgb(0,0,255)">switch</span>(c)
<span style = "background-color: #F0F0F0;">358</span>| 					{
<span style = "background-color: #F0F0F0;">359</span>| 						<span style="color: rgb(0,0,255)">case</span> '1':add(); <span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">360</span>| 						<span style="color: rgb(0,0,255)">case</span> '2':<span style="color: rgb(0,0,255)">if</span>(!op.inc_o.empty()){<span style="color: rgb(0,0,255)">while</span>(check(op.inc_o));<span style="color: rgb(0,0,255)">return</span> 1;}<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">361</span>| 						<span style="color: rgb(0,0,255)">case</span> 27:<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">362</span>| 						<span style="color: rgb(0,0,255)">default</span>	:;
<span style = "background-color: #F0F0F0;">363</span>| 					}
<span style = "background-color: #F0F0F0;">364</span>| 				}
<span style = "background-color: #F0F0F0;">365</span>| 				<span style="color: rgb(0,0,255)">else</span>
<span style = "background-color: #F0F0F0;">366</span>| 				{
<span style = "background-color: #F0F0F0;">367</span>| 					<span style="color: rgb(0,0,255)">switch</span>(c)
<span style = "background-color: #F0F0F0;">368</span>| 					{
<span style = "background-color: #F0F0F0;">369</span>| 						<span style="color: rgb(0,0,255)">case</span> '1':add();<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">370</span>| 						<span style="color: rgb(0,0,255)">case</span> '2':<span style="color: rgb(0,0,255)">while</span>(check(op.inc));<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">371</span>| 						<span style="color: rgb(0,0,255)">case</span> '3':<span style="color: rgb(0,0,255)">if</span>(!op.inc_o.empty()){<span style="color: rgb(0,0,255)">while</span>(check(op.inc_o));<span style="color: rgb(0,0,255)">return</span> 1;}<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">372</span>| 						<span style="color: rgb(0,0,255)">case</span> 27:<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">373</span>| 						<span style="color: rgb(0,0,255)">default</span>	:;
<span style = "background-color: #F0F0F0;">374</span>| 					}
<span style = "background-color: #F0F0F0;">375</span>| 				}
<span style = "background-color: #F0F0F0;">376</span>| 			}
<span style = "background-color: #F0F0F0;">377</span>| 			GoToXY(0,1);
<span style = "background-color: #F0F0F0;">378</span>| 			nt=time(0);
<span style = "background-color: #F0F0F0;">379</span>| 			cout&#60;&#60;"\t\t系统时间:  "&#60;&#60;ctime(&#38;nt)&#60;&#60;endl&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">380</span>| 			Sleep(200);
<span style = "background-color: #F0F0F0;">381</span>| 		}
<span style = "background-color: #F0F0F0;">382</span>| 	}
<span style = "background-color: #F0F0F0;">383</span>| 	<span style="color: rgb(0,0,255)">int</span> set_(vector&#60;incident&#62; &#38;inc,<span style="color: rgb(0,0,255)">int</span> vi,<span style="color: rgb(0,0,255)">char</span> c)<span style="color: rgb(128,128,128)">//各属性修改界面 参数分别为 事件表,事件位置,修改内容参数</span>
<span style = "background-color: #F0F0F0;">384</span>| 	{
<span style = "background-color: #F0F0F0;">385</span>| 		string s;
<span style = "background-color: #F0F0F0;">386</span>| 		<span style="color: rgb(0,0,255)">int</span> t,legal_len;
<span style = "background-color: #F0F0F0;">387</span>| 		<span style="color: rgb(0,0,255)">int</span> state=0;
<span style = "background-color: #F0F0F0;">388</span>| 		<span style="color: rgb(0,0,255)">while</span>(vi&#60;inc.size())
<span style = "background-color: #F0F0F0;">389</span>| 		{
<span style = "background-color: #F0F0F0;">390</span>| 			system("cls");
<span style = "background-color: #F0F0F0;">391</span>| 			GoToXY(40,21);
<span style = "background-color: #F0F0F0;">392</span>| 			cout&#60;&#60;"结构化程序设计课程设计"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">393</span>| 			GoToXY(35,23);
<span style = "background-color: #F0F0F0;">394</span>| 			cout&#60;&#60;"Designed By 09计机5 @ SCAU 连泽祺"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">395</span>| 			GoToXY(0,0);
<span style = "background-color: #F0F0F0;">396</span>| 			cout&#60;&#60;"\t\t***************************************"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">397</span>| 			cout&#60;&#60;"\t\t当前事件属性: \n";
<span style = "background-color: #F0F0F0;">398</span>| 			print(inc[vi]);
<span style = "background-color: #F0F0F0;">399</span>| 			cout&#60;&#60;"\t\t***************************************"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">400</span>| 			<span style="color: rgb(0,0,255)">if</span>(state==1)cout&#60;&#60;"\n\t\t输入不合法!!"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">401</span>| 			<span style="color: rgb(0,0,255)">switch</span>(c)
<span style = "background-color: #F0F0F0;">402</span>| 			{
<span style = "background-color: #F0F0F0;">403</span>| 				<span style="color: rgb(0,0,255)">case</span> 'l':s="标题";<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">404</span>| 				<span style="color: rgb(0,0,255)">case</span> 'b':s="内容";<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">405</span>| 				<span style="color: rgb(0,0,255)">case</span> 'y':legal_len=4;s="年份";<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">406</span>| 				<span style="color: rgb(0,0,255)">case</span> 'm':legal_len=2;s="月份";<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">407</span>| 				<span style="color: rgb(0,0,255)">case</span> 'd':legal_len=2;s="日期";<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">408</span>| 				<span style="color: rgb(0,0,255)">case</span> 'h':legal_len=2;s="时间(小时)";<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">409</span>| 				<span style="color: rgb(0,0,255)">case</span> 'n':legal_len=2;s="时间(分钟)";<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">410</span>| 				<span style="color: rgb(0,0,255)">case</span> 'i':legal_len=4;s="间隔时间";<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">411</span>| 				<span style="color: rgb(0,0,255)">case</span> 'w':legal_len=2;s="提醒次数";<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">412</span>| 			}
<span style = "background-color: #F0F0F0;">413</span>| 			cout&#60;&#60;"\n\t\t请输入新的"&#60;&#60;s&#60;&#60;"(可直接回车跳过) :";
<span style = "background-color: #F0F0F0;">414</span>| 			t=0;
<span style = "background-color: #F0F0F0;">415</span>| 			s="";
<span style = "background-color: #F0F0F0;">416</span>| 			getline(cin,s,'\n');
<span style = "background-color: #F0F0F0;">417</span>| 			<span style="color: rgb(0,0,255)">if</span>(s.empty()) <span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">418</span>| 			<span style="color: rgb(0,0,255)">else</span> <span style="color: rgb(0,0,255)">if</span>(s.size()&#60;=legal_len)
<span style = "background-color: #F0F0F0;">419</span>| 			{
<span style = "background-color: #F0F0F0;">420</span>| 				<span style="color: rgb(0,0,255)">for</span>(<span style="color: rgb(0,0,255)">int</span> i=s.size()-1,j=1;i&#62;=0;i--,j*=10)
<span style = "background-color: #F0F0F0;">421</span>| 				{
<span style = "background-color: #F0F0F0;">422</span>| 					t+=(s[i]-'0')*j;
<span style = "background-color: #F0F0F0;">423</span>| 				}
<span style = "background-color: #F0F0F0;">424</span>| 			}
<span style = "background-color: #F0F0F0;">425</span>| 			<span style="color: rgb(0,0,255)">switch</span>(c)
<span style = "background-color: #F0F0F0;">426</span>| 			{
<span style = "background-color: #F0F0F0;">427</span>| 				<span style="color: rgb(0,0,255)">case</span> 'l':<span style="color: rgb(0,0,255)">if</span>(inc[vi].set_title(s)) <span style="color: rgb(0,0,255)">return</span> 1;<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">428</span>| 				<span style="color: rgb(0,0,255)">case</span> 'b':<span style="color: rgb(0,0,255)">if</span>(inc[vi].set_body(s)) <span style="color: rgb(0,0,255)">return</span> 1;<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">429</span>| 				<span style="color: rgb(0,0,255)">case</span> 'y':<span style="color: rgb(0,0,255)">if</span>(inc[vi].set_year(t)) <span style="color: rgb(0,0,255)">return</span> 1;<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">430</span>| 				<span style="color: rgb(0,0,255)">case</span> 'm':<span style="color: rgb(0,0,255)">if</span>(inc[vi].set_mon(t)) <span style="color: rgb(0,0,255)">return</span> 1;<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">431</span>| 				<span style="color: rgb(0,0,255)">case</span> 'd':<span style="color: rgb(0,0,255)">if</span>(inc[vi].set_day(t)) <span style="color: rgb(0,0,255)">return</span> 1;<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">432</span>| 				<span style="color: rgb(0,0,255)">case</span> 'h':<span style="color: rgb(0,0,255)">if</span>(inc[vi].set_hour(t)) <span style="color: rgb(0,0,255)">return</span> 1;<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">433</span>| 				<span style="color: rgb(0,0,255)">case</span> 'n':<span style="color: rgb(0,0,255)">if</span>(inc[vi].set_min(t)) <span style="color: rgb(0,0,255)">return</span> 1;<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">434</span>| 				<span style="color: rgb(0,0,255)">case</span> 'i':<span style="color: rgb(0,0,255)">if</span>(inc[vi].set_interval(t)) <span style="color: rgb(0,0,255)">return</span> 1;<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">435</span>| 				<span style="color: rgb(0,0,255)">case</span> 'w':<span style="color: rgb(0,0,255)">if</span>(inc[vi].set_warn_times(t)) <span style="color: rgb(0,0,255)">return</span> 1;<span style="color: rgb(0,0,255)">break</span>;
<span style = "background-color: #F0F0F0;">436</span>| 			}
<span style = "background-color: #F0F0F0;">437</span>| 			state=1;
<span style = "background-color: #F0F0F0;">438</span>| 		}
<span style = "background-color: #F0F0F0;">439</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">440</span>| 	}
<span style = "background-color: #F0F0F0;">441</span>| 	<span style="color: rgb(0,0,255)">void</span> add()<span style="color: rgb(128,128,128)">//添加事件</span>
<span style = "background-color: #F0F0F0;">442</span>| 	{
<span style = "background-color: #F0F0F0;">443</span>| 		op.add();
<span style = "background-color: #F0F0F0;">444</span>| 		<span style="color: rgb(0,0,255)">int</span> p=op.inc.size()-1;
<span style = "background-color: #F0F0F0;">445</span>| 		set_(op.inc,p,'l');
<span style = "background-color: #F0F0F0;">446</span>| 		set_(op.inc,p,'b');
<span style = "background-color: #F0F0F0;">447</span>| 		set_(op.inc,p,'y');
<span style = "background-color: #F0F0F0;">448</span>| 		set_(op.inc,p,'m');
<span style = "background-color: #F0F0F0;">449</span>| 		set_(op.inc,p,'d');
<span style = "background-color: #F0F0F0;">450</span>| 		set_(op.inc,p,'h');
<span style = "background-color: #F0F0F0;">451</span>| 		set_(op.inc,p,'n');
<span style = "background-color: #F0F0F0;">452</span>| 		set_(op.inc,p,'w');
<span style = "background-color: #F0F0F0;">453</span>| 		set_(op.inc,p,'i');
<span style = "background-color: #F0F0F0;">454</span>| 		op._sort();
<span style = "background-color: #F0F0F0;">455</span>| 		op.save();
<span style = "background-color: #F0F0F0;">456</span>| 		op.load();
<span style = "background-color: #F0F0F0;">457</span>| 	}
<span style = "background-color: #F0F0F0;">458</span>| 	<span style="color: rgb(0,0,255)">int</span> modify(vector&#60;incident&#62; &#38;inc,<span style="color: rgb(0,0,255)">int</span> vi)<span style="color: rgb(128,128,128)">//单事件查看修改界面</span>
<span style = "background-color: #F0F0F0;">459</span>| 	{
<span style = "background-color: #F0F0F0;">460</span>| 		<span style="color: rgb(0,0,255)">char</span> c;
<span style = "background-color: #F0F0F0;">461</span>| 		<span style="color: rgb(0,0,255)">if</span>(vi&#62;=inc.size()) <span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">462</span>| 		system("cls");
<span style = "background-color: #F0F0F0;">463</span>| 		GoToXY(40,21);
<span style = "background-color: #F0F0F0;">464</span>| 		cout&#60;&#60;"结构化程序设计课程设计"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">465</span>| 		GoToXY(35,23);
<span style = "background-color: #F0F0F0;">466</span>| 		cout&#60;&#60;"Designed By 09计机5 @ SCAU 连泽祺"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">467</span>| 		GoToXY(0,0);
<span style = "background-color: #F0F0F0;">468</span>| 		cout&#60;&#60;"\t\t***************************************"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">469</span>| 		nt=time(0);
<span style = "background-color: #F0F0F0;">470</span>| 		cout&#60;&#60;"\t\t系统时间:  "&#60;&#60;ctime(&#38;nt);
<span style = "background-color: #F0F0F0;">471</span>| 		cout&#60;&#60;"\t\t***************************************"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">472</span>| 		cout&#60;&#60;"\t\t已选择的提醒事件: \n"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">473</span>| 		print(inc[vi]);
<span style = "background-color: #F0F0F0;">474</span>| 		cout&#60;&#60;endl&#60;&#60;"\t\t请输入选项 : \n"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">475</span>| 		cout&#60;&#60;"\t\t1.修改标题 2.修改内容 3.修改日期 4.修改时间 "&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">476</span>| 		cout&#60;&#60;"\n\t\t5.修改提醒间隔 6.修改提醒次数"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">477</span>| 		cout&#60;&#60;"\n\t\tEsc 保存并返回  D.删除事件"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">478</span>| 		<span style="color: rgb(0,0,255)">while</span>(1)
<span style = "background-color: #F0F0F0;">479</span>| 		{
<span style = "background-color: #F0F0F0;">480</span>| 			<span style="color: rgb(0,0,255)">if</span>(kbhit())
<span style = "background-color: #F0F0F0;">481</span>| 			{
<span style = "background-color: #F0F0F0;">482</span>| 				<span style="color: rgb(0,0,255)">char</span> c=getch();
<span style = "background-color: #F0F0F0;">483</span>| 				<span style="color: rgb(0,0,255)">if</span>(c&#62;='A'&#38;&#38;c&#60;='Z') c+=32;
<span style = "background-color: #F0F0F0;">484</span>| 				<span style="color: rgb(0,0,255)">switch</span>(c)
<span style = "background-color: #F0F0F0;">485</span>| 				{
<span style = "background-color: #F0F0F0;">486</span>| 					<span style="color: rgb(0,0,255)">case</span> '1':set_(inc,vi,'l');op.save();<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">487</span>| 					<span style="color: rgb(0,0,255)">case</span> '2':set_(inc,vi,'b');op.save();<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">488</span>| 					<span style="color: rgb(0,0,255)">case</span> '3':set_(inc,vi,'y');set_(inc,vi,'m');set_(inc,vi,'d');<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">489</span>| 					<span style="color: rgb(0,0,255)">case</span> '4':set_(inc,vi,'h');set_(inc,vi,'n');<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">490</span>| 					<span style="color: rgb(0,0,255)">case</span> '5':set_(inc,vi,'i');<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">491</span>| 					<span style="color: rgb(0,0,255)">case</span> '6':set_(inc,vi,'w');<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">492</span>| 					<span style="color: rgb(0,0,255)">case</span> 'd':op.del(vi,inc); <span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">493</span>| 					<span style="color: rgb(0,0,255)">case</span> 27: <span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">494</span>| 					<span style="color: rgb(0,0,255)">default</span> :;
<span style = "background-color: #F0F0F0;">495</span>| 				}
<span style = "background-color: #F0F0F0;">496</span>| 			}
<span style = "background-color: #F0F0F0;">497</span>| 			GoToXY(0,1);
<span style = "background-color: #F0F0F0;">498</span>| 			nt=time(0);
<span style = "background-color: #F0F0F0;">499</span>| 			cout&#60;&#60;"\t\t系统时间:  "&#60;&#60;ctime(&#38;nt)&#60;&#60;endl&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">500</span>| 			Sleep(200);
<span style = "background-color: #F0F0F0;">501</span>| 		}
<span style = "background-color: #F0F0F0;">502</span>| 		<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">503</span>| 	}
<span style = "background-color: #F0F0F0;">504</span>| 	<span style="color: rgb(0,0,255)">int</span> check(vector&#60;incident&#62; &#38;inc)<span style="color: rgb(128,128,128)">//事件表查看界面</span>
<span style = "background-color: #F0F0F0;">505</span>| 	{
<span style = "background-color: #F0F0F0;">506</span>| 		<span style="color: rgb(0,0,255)">int</span> pages=(inc.size()-1)/4+1;
<span style = "background-color: #F0F0F0;">507</span>| 		<span style="color: rgb(0,0,255)">static</span> <span style="color: rgb(0,0,255)">int</span> page=-1;
<span style = "background-color: #F0F0F0;">508</span>| 		<span style="color: rgb(0,0,255)">if</span>(inc.empty()) <span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">509</span>| 		<span style="color: rgb(0,0,255)">if</span>(page==-1) page=1;
<span style = "background-color: #F0F0F0;">510</span>| 		system("cls");
<span style = "background-color: #F0F0F0;">511</span>| 		GoToXY(40,21);
<span style = "background-color: #F0F0F0;">512</span>| 		cout&#60;&#60;"结构化程序设计课程设计"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">513</span>| 		GoToXY(35,23);
<span style = "background-color: #F0F0F0;">514</span>| 		cout&#60;&#60;"Designed By 09计机5 @ SCAU 连泽祺"&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">515</span>| 		GoToXY(0,0);
<span style = "background-color: #F0F0F0;">516</span>| 		cout&#60;&#60;"\t\t***************************************"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">517</span>| 		nt=time(0);
<span style = "background-color: #F0F0F0;">518</span>| 		cout&#60;&#60;"\t\t系统时间:  "&#60;&#60;ctime(&#38;nt);
<span style = "background-color: #F0F0F0;">519</span>| 		cout&#60;&#60;"\t\t***************************************\n"	&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">520</span>| 		<span style="color: rgb(0,0,255)">for</span>(<span style="color: rgb(0,0,255)">int</span> i=4*(page-1);i&#60;4*page&#38;&#38;i&#60;inc.size();i++)
<span style = "background-color: #F0F0F0;">521</span>| 		{
<span style = "background-color: #F0F0F0;">522</span>| 			cout&#60;&#60;"\t\t"&#60;&#60;i%4+1&#60;&#60;".\t标题: "&#60;&#60;inc[i].get_title()&#60;&#60;endl&#60;&#60;"\t\t\t时间: "&#60;&#60;ctime(inc[i].get_time())&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">523</span>| 		}
<span style = "background-color: #F0F0F0;">524</span>| 		GoToXY(0,15);
<span style = "background-color: #F0F0F0;">525</span>| 		cout&#60;&#60;"\t\t                               "&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">526</span>| 		cout&#60;&#60;endl&#60;&#60;"\t\t请选择序号: "&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">527</span>| 		cout&#60;&#60;endl&#60;&#60;"\t\tEsc:返回主菜单  C:清空列表  B:上一页  N:下一页  页数"&#60;&#60;page&#60;&#60;"/"&#60;&#60;pages&#60;&#60;endl;
<span style = "background-color: #F0F0F0;">528</span>| 		<span style="color: rgb(0,0,255)">while</span>(1)
<span style = "background-color: #F0F0F0;">529</span>| 		{
<span style = "background-color: #F0F0F0;">530</span>| 			<span style="color: rgb(0,0,255)">if</span>(alarm()) <span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">531</span>| 			<span style="color: rgb(0,0,255)">if</span>(kbhit())
<span style = "background-color: #F0F0F0;">532</span>| 			{
<span style = "background-color: #F0F0F0;">533</span>| 				<span style="color: rgb(0,0,255)">char</span> c=getch();
<span style = "background-color: #F0F0F0;">534</span>| 				<span style="color: rgb(0,0,255)">if</span>(c&#62;='A'&#38;&#38;c&#60;='Z') c+=32;
<span style = "background-color: #F0F0F0;">535</span>| 				<span style="color: rgb(0,0,255)">if</span>(c=='n'||c=='b')
<span style = "background-color: #F0F0F0;">536</span>| 				{
<span style = "background-color: #F0F0F0;">537</span>| 					<span style="color: rgb(0,0,255)">if</span>(c=='n'&#38;&#38;page&#60;pages)
<span style = "background-color: #F0F0F0;">538</span>| 						++page;
<span style = "background-color: #F0F0F0;">539</span>| 					<span style="color: rgb(0,0,255)">else</span> <span style="color: rgb(0,0,255)">if</span>(c=='b'&#38;&#38;page&#62;1)
<span style = "background-color: #F0F0F0;">540</span>| 					{
<span style = "background-color: #F0F0F0;">541</span>| 						--page;
<span style = "background-color: #F0F0F0;">542</span>| 					}
<span style = "background-color: #F0F0F0;">543</span>| 					<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">544</span>| 				}
<span style = "background-color: #F0F0F0;">545</span>| 				<span style="color: rgb(0,0,255)">else</span> <span style="color: rgb(0,0,255)">if</span>(c==27)
<span style = "background-color: #F0F0F0;">546</span>| 				{
<span style = "background-color: #F0F0F0;">547</span>| 					page=1;
<span style = "background-color: #F0F0F0;">548</span>| 					<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">549</span>| 				}
<span style = "background-color: #F0F0F0;">550</span>| 				<span style="color: rgb(0,0,255)">else</span> <span style="color: rgb(0,0,255)">if</span>(c=='c')
<span style = "background-color: #F0F0F0;">551</span>| 				{
<span style = "background-color: #F0F0F0;">552</span>| 					inc.clear();
<span style = "background-color: #F0F0F0;">553</span>| 					op.save();
<span style = "background-color: #F0F0F0;">554</span>| 					op.load();
<span style = "background-color: #F0F0F0;">555</span>| 					<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">556</span>| 				}
<span style = "background-color: #F0F0F0;">557</span>| 				<span style="color: rgb(0,0,255)">else</span> <span style="color: rgb(0,0,255)">if</span>(c&#62;='1'&#38;&#38;c&#60;='4')
<span style = "background-color: #F0F0F0;">558</span>| 				{
<span style = "background-color: #F0F0F0;">559</span>| 					<span style="color: rgb(0,0,255)">while</span>(modify(inc,c-1-'0'+4*(page-1)));
<span style = "background-color: #F0F0F0;">560</span>| 					op.save();
<span style = "background-color: #F0F0F0;">561</span>| 					op.load();
<span style = "background-color: #F0F0F0;">562</span>| 					<span style="color: rgb(0,0,255)">return</span> 1;
<span style = "background-color: #F0F0F0;">563</span>| 				}
<span style = "background-color: #F0F0F0;">564</span>| 			}
<span style = "background-color: #F0F0F0;">565</span>| 			GoToXY(0,1);
<span style = "background-color: #F0F0F0;">566</span>| 			nt=time(0);
<span style = "background-color: #F0F0F0;">567</span>| 			cout&#60;&#60;"\t\t系统时间:  "&#60;&#60;ctime(&#38;nt);
<span style = "background-color: #F0F0F0;">568</span>| 			Sleep(200);
<span style = "background-color: #F0F0F0;">569</span>| 		}
<span style = "background-color: #F0F0F0;">570</span>| 	}
<span style = "background-color: #F0F0F0;">571</span>| 	<span style="color: rgb(0,0,255)">void</span> GoToXY(<span style="color: rgb(0,0,255)">int</span> x, <span style="color: rgb(0,0,255)">int</span> y)<span style="color: rgb(128,128,128)">//光标定位</span>
<span style = "background-color: #F0F0F0;">572</span>| 	{
<span style = "background-color: #F0F0F0;">573</span>|         COORD pos = {x,y};
<span style = "background-color: #F0F0F0;">574</span>|         HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);        <span style="color: rgb(128,128,128)">// 获取标准输出设备句柄</span>
<span style = "background-color: #F0F0F0;">575</span>|         SetConsoleCursorPosition(hOut, pos);
<span style = "background-color: #F0F0F0;">576</span>| 	}<span style="color: rgb(128,128,128)">//网上扒的代码...进行光标定位...http://www.cssdn.net/thread-406-1-1.html  感谢 zhuyonge</span>
<span style = "background-color: #F0F0F0;">577</span>| };
<span style = "background-color: #F0F0F0;">578</span>| <span style="color: rgb(0,0,255)">int</span> main()
<span style = "background-color: #F0F0F0;">579</span>| {
<span style = "background-color: #F0F0F0;">580</span>| 	ui u;<span style="color: rgb(128,128,128)">//界面对象</span>
<span style = "background-color: #F0F0F0;">581</span>| 	<span style="color: rgb(0,0,255)">while</span>(u.index());<span style="color: rgb(128,128,128)">//执行主菜单</span>
<span style = "background-color: #F0F0F0;">582</span>| 	<span style="color: rgb(0,0,255)">return</span> 0;
<span style = "background-color: #F0F0F0;">583</span>| }
</body>
</html>
